%%function drawAULCSF(au_pre_t_f, au_pre_t_n, au_post_t_f,au_post_t_n,au_pre_ct_f, au_pre_ct_n, au_post_ct_f,au_post_ct_n,au_pre_c_f, au_pre_c_n, au_post_c_f,au_post_c_n)
colors = [2 158 154; 255 189 7; 211 57 33]/255;

%%
figure('color',[1 1 1])

colors2 = colors*1.2;
colors2(colors2>1) = 1;

data_diff = [(au_post_t_n-au_pre_t_n)./au_pre_t_n (au_post_ct_n-au_pre_ct_n)./au_pre_ct_n (au_post_c_n-au_pre_c_n)./au_pre_c_n]*100;
data_diff2 = [(au_post_t_f-au_pre_t_f)./au_pre_t_f (au_post_ct_f-au_pre_ct_f)./au_pre_ct_f (au_post_c_f-au_pre_c_f)./au_pre_c_f]*100;

dataF = [data_diff(:,1) data_diff2(:,1) data_diff(:,2) data_diff2(:,2) data_diff(:,3) data_diff2(:,3)];
xaxisF = [1 2 4 5 7 8];
colorsF = repelem(colors,2,1);
colorsF2 = repelem(colors2,2,1);

for bb = 1:6
    b = bar(xaxisF(bb),mean(dataF(:,bb)));
    b.FaceColor = 'flat';
    b.LineWidth= 1;
    b.CData(1,:) = colorsF(bb,:);
    hold on
    % without marker edge
%      plot(xaxisF(bb),dataF(:,bb),'o', 'MarkerEdgeColor' ,'none', 'MarkerFaceColor' ,colorsF2(bb,:),'MarkerSize',7);
     % with marker edge
% %     plot(xaxisF(bb),dataF(:,bb),'o', 'MarkerEdgeColor' ,[0 0 0], 'MarkerFaceColor' ,colorsF2(bb,:),'MarkerSize',7);
    plot(xaxisF(bb),dataF(:,bb),'o', 'MarkerEdgeColor' ,[0.7 0.7 0.7], 'MarkerFaceColor' ,colorsF2(bb,:),'MarkerSize',7);
    hold on
    bars{bb,1} = b;
end

% remove outlier
% % plot(xaxisF(1),dataF(8,1),'kx','MarkerFaceColor',[1 1 1],'MarkerSize',15,'linewidth',1.5); hold on
% % plot(xaxisF(3),dataF(8,3),'kx','MarkerFaceColor',[1 1 1],'MarkerSize',15,'linewidth',1.5); hold on

% Uncomment not to remove outlier
plot(xaxisF(1),dataF(8,1),'x','MarkerEdgeColor' ,[0.7 0.7 0.7],'MarkerSize',15,'linewidth',1.5); hold on
plot(xaxisF(3),dataF(8,3),'x','MarkerEdgeColor' ,[0.7 0.7 0.7],'MarkerSize',15,'linewidth',1.5); hold on



errorbar(xaxisF,nanmean(dataF),nanstd(dataF)/sqrt(8),'ko','MarkerFaceColor',[1 1 1],'linewidth',1,'CapSize',0)
set(gca,'xtick',xaxisF,'xticklabel',{'Near','Far','Near','Far','Near','Far','Near','Far'},'ylim',[-35 40],'FontName', 'Arial','fontsize',10,'linewidth',1);
l = cell(1,3);
l{1}='Alternating'; l{2}='Fixed'; l{3}='Control';
[hLg, icons] = legend([bars{1,1},bars{3,1}, bars{5,1}],l,'location','southwest');
legend boxoff

icons = findobj(icons,'Type','patch');
% icons = findobj(icons,'Marker','none','-xor');
set(icons(1),'Vertices',[3*(icons(1).Vertices(:,1)/4) (icons(1).Vertices(:,2))]);
set(icons(2),'Vertices',[3*(icons(2).Vertices(:,1)/4) (icons(2).Vertices(:,2))]);
set(icons(3),'Vertices',[3*(icons(3).Vertices(:,1)/4) (icons(3).Vertices(:,2))]);

box off
% set(gca,'xticklabel',{'Alternating','Fixed','Control'});
ylabel('AULCSF improvement (%)', 'FontName', 'Arial');

% set(gcf,'units','centimeters','position',[0 0 19 9])
set(gcf,'units','centimeters','position',[0 0 11.5 9])